#ifndef __EXPORT__
#define __EXPORT__

#include "Export.h"



IKernel * glbPtrKernel = nullptr;
ICientCache * glbPtrClientCache = nullptr;
IClientCheckRisk * glbPtrClientCheckRisk = nullptr;
__declspec(dllexport) bool __cdecl AddInstance(IKernel * ptrKernel)
{
	bool bRetVal = false;
	try
	{
		glbPtrKernel = ptrKernel;
		ptrKernel->AddInstance(CClientCache::Instance());
		ptrKernel->AddInstance(CClientCheckRisk::Instance());
	}
	catch (...)
	{
		goto __end;
	}
	bRetVal = true;
__end:
	return bRetVal;
}

__declspec(dllexport) bool __cdecl  CheckRisk(PST_RISK_PARA ptrRiskPara)
{
	return glbPtrClientCheckRisk == nullptr ? false : glbPtrClientCheckRisk->CheckRisk(ptrRiskPara);
}
__declspec(dllexport) bool __cdecl ConfirmOrder(int iOptNum, long long RecordNo, bool isConfirm)
{
  return glbPtrClientCheckRisk == nullptr ? false : glbPtrClientCheckRisk->ConfirmOrder(iOptNum, RecordNo, isConfirm);
}

__declspec(dllexport) bool __cdecl InitRisk()
{
	if (glbPtrKernel == nullptr)
	{
		return false;
	}
	glbPtrClientCache = Instance<ICientCache>(glbPtrKernel, "CClientCache", nullptr, nullptr, 0);
	glbPtrClientCheckRisk = Instance<IClientCheckRisk>(glbPtrKernel, "CClientCheckRisk", nullptr, nullptr, 0);
	return glbPtrClientCache != nullptr && glbPtrClientCheckRisk != nullptr;
}

__declspec(dllexport) bool __cdecl SetRiskInfo(const char *szRiskDataSet)
{
	return glbPtrClientCheckRisk == nullptr ? false : glbPtrClientCheckRisk->SetRiskInfo(szRiskDataSet);
}


__declspec(dllexport) bool __cdecl SetRiskInfoData(void *pRiskDataSet, const int nItems)
{
	return glbPtrClientCheckRisk == nullptr ? false : glbPtrClientCheckRisk->SetRiskInfoData(pRiskDataSet, nItems);
}

__declspec(dllexport) bool __cdecl RegisterLbmResult(const char * pszLbmNo, const char * pszKey, const char * pszLbmResult)
{
	return glbPtrClientCache == nullptr? false: glbPtrClientCache->RegisterLbmResult(pszLbmNo, pszKey, pszLbmResult);
}

__declspec(dllexport) bool __cdecl LoadRiskInfo(const char * pszLbmNo, const char * pszKey, const char * pszInPara)
{
	return glbPtrClientCache == nullptr ? false : glbPtrClientCache->LoadRiskInfo(pszLbmNo, pszKey, pszInPara);
}

__declspec(dllexport) const char *  __cdecl GetValueAsString(const char * pszLbmNo, const char * pszKey, const char * pszFieldName, char * pszValue, int iSize, const int iRecNo)
{
	return glbPtrClientCache == nullptr ? nullptr : glbPtrClientCache->GetValueAsString(pszLbmNo, pszKey, pszFieldName, pszValue, iSize, iRecNo);
}

__declspec(dllexport) long long __cdecl GetValueAsInt(const char * pszLbmNo, const char * pszKey, const char * pszFieldName, const int iRecNo)
{
	return glbPtrClientCache == nullptr ? 0 : glbPtrClientCache->GetValueAsInt(pszLbmNo, pszKey, pszFieldName);
}

__declspec(dllexport) double __cdecl GetValueAsFloat(const char * pszLbmNo, const char * pszKey, const char * pszFieldName, const int iRecNo)
{
	return glbPtrClientCache == nullptr ? 0 : glbPtrClientCache->GetValueAsFloat(pszLbmNo, pszKey, pszFieldName);
}

__declspec(dllexport) bool __cdecl GetValueAsBool(const char * pszLbmNo, const char * pszKey, const char * pszFieldName, const int iRecNo)
{
	return glbPtrClientCache == nullptr ? false : glbPtrClientCache->GetValueAsBool(pszLbmNo, pszKey, pszFieldName);
}

#endif//__EXPORT__